﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WindowsFormsApplication1.DAL;
using WindowsFormsApplication1.BLL;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        PersistanceUtility pu;
        public Form1()
        {
            InitializeComponent();
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            pu = new PersistanceUtility();

            dataGridView1.DataSource = pu.GetPersonList();
        }


        private void addButton_Click(object sender, EventArgs e)
        {
            Person myPerson = new Person();
            myPerson.FirstName = firstNameTextBox.Text;
            myPerson.LastName = lastNameTextBox.Text;
            myPerson.Phone = phoneTextBox.Text;
            myPerson.BrushColor = brushColorTextBox.Text;


            pu.AddPerson(myPerson);

            firstNameTextBox.Text = "";
            lastNameTextBox.Text = "";
            phoneTextBox.Text = "";
            brushColorTextBox.Text = "";

            dataGridView1.DataSource = pu.GetPersonList();
        }

 
    }
}
